package com.aspose.cells;

import java.util.HashMap;

class zfi implements zafp {
   private zahx[] a;
   private zahn[] b;
   private int c = -1;
   private int d = -1;
   private int e = -1;

   zfi(int var1) {
      this.a = new zahx[var1];
      this.b = new zahn[var1];
   }

   zfi(int var1, int var2, int var3) {
      this.a = new zahx[var1];
      this.b = new zahn[var1];
      this.c = var2;
      this.d = var3;
   }

   public boolean a() {
      return true;
   }

   public void a(boolean var1) {
      zahx[] var2 = this.a;
      int var3 = var2.length;

      for(int var4 = 0; var4 < var3; ++var4) {
         zahx var5 = var2[var4];
         var5.a(var1);
      }

   }

   public void a(zaay var1) {
      for(this.e = 0; this.e < this.a.length; ++this.e) {
         zahx var2 = this.a[this.e];
         if (var2 != null) {
            zahx var3 = var2.d(var1);
            if (var3 != var2) {
               var3.a(true);
               this.a[this.e] = var3;
            }
         }
      }

      this.e = -1;
      this.c = -1;
      this.d = -1;
   }

   zagu a(zagu var1, zagu var2, zaay var3) {
      ++this.e;
      zahn var4;
      if (this.a[this.e] != null) {
         var4 = this.a[this.e].c(var3);
         if (var4 != null) {
            if (!var4.a()) {
               var4 = var4.b(var3);
            }

            var4.a(var3);
            this.b[this.e] = var4;
            if (this.c < 0) {
               this.c = var4.c();
               this.d = var4.d();
            }

            return null;
         }
      }

      zagu var5 = zaaq.a(var1, var3);
      if (var5.b() != 9) {
         if (this.e > 0) {
            --this.e;

            while(this.e > -1) {
               this.b[this.e].a(true);
               --this.e;
            }
         }

         return var5;
      } else {
         zaye var6 = ((zaal)var5).k();
         if (this.c < 0) {
            this.c = var6.q();
            this.d = var6.p();
         } else if (var6.q() != this.c || var6.p() != this.d) {
            if (this.e > 0) {
               --this.e;

               while(this.e > -1) {
                  this.b[this.e].a(true);
                  --this.e;
               }
            }

            return zzg.a;
         }

         zmt var7 = zaaq.a(var2, var3, false);
         String var8 = null;
         int var9 = var3.m;
         if (var3.k) {
            if (this.a[this.e] == zbme.a) {
               var3.m = 0;
            } else {
               var3.c();
               var3.m &= var2.b(var3, false);
            }

            var4 = var1.a(var3, false);
         } else {
            if (this.c > 100 || this.d > 100) {
               zur var10 = var6.a();
               if (var10 == null) {
                  var10 = var3.o;
               }

               StringBuilder var11 = new StringBuilder(32);
               var11.append(var10.a).append('-').append(var10.b).append('-').append(CellsHelper.cellIndexToName(var6.b(), var6.d())).append(':').append(CellsHelper.cellIndexToName(var6.f(), var6.h()));
               var7.d().b(var11, var3);
               var7.b().a(var11, var3);
               var8 = com.aspose.cells.b.a.zr.a(var11);
               if (var3.p.E == null) {
                  var3.p.E = new HashMap();
               } else {
                  Object var12 = var3.p.E.get(var8);
                  if (var12 != null) {
                     zahn var13 = (zahn)var12;
                     zahn var14 = (zahn)var13.d(var3);
                     if (var14 != var13) {
                        var3.p.E.put(var8, var14);
                     } else {
                        if (!var14.a()) {
                           var14 = var14.b(var3);
                           var3.p.E.put(var8, var14);
                        }

                        if (var14 instanceof zawy) {
                           var14.f();

                           while(var14.g() && var14.h().f()) {
                              ;
                           }

                           var14 = (zahn)var14.d(var3);
                           var3.p.E.put(var8, var14);
                        }
                     }

                     this.b[this.e] = var14;
                     return null;
                  }
               }
            }

            var4 = var5.a(var3, false);
         }

         Object var15 = new zawt(var4, new zlb(var3, var7, var3.g, var3.h), var3);
         if (var3.k) {
            switch(var3.m) {
            case 1:
               if (var3.l.e() > 1) {
                  if (((zahn)var15).A()) {
                     var15 = zayc.a((zahn)var15, var3);
                  }

                  if (var3.l.f() > 1) {
                     if (this.a[this.e] == null) {
                        this.a[this.e] = new zbmd(var3, false);
                     }

                     this.a[this.e].a(var3, (zahn)var15);
                  } else {
                     this.a[this.e] = (zahx)var15;
                  }
               } else {
                  this.a[this.e] = zbme.a;
               }
               break;
            case 2:
               if (var3.l.f() > 1) {
                  if (((zahn)var15).A()) {
                     var15 = zayc.a((zahn)var15, var3);
                  }

                  if (var3.l.e() > 1) {
                     if (this.a[this.e] == null) {
                        this.a[this.e] = new zbmd(var3, true);
                     }

                     this.a[this.e].a(var3, (zahn)var15);
                  } else {
                     this.a[this.e] = (zahx)var15;
                  }
               } else {
                  this.a[this.e] = zbme.a;
               }
               break;
            case 3:
               var15 = zayc.a((zahn)var15, var3);
               this.a[this.e] = (zahx)var15;
               break;
            default:
               this.a[this.e] = zbme.a;
            }

            var3.m = var9;
         } else if (var8 != null) {
            var15 = zayc.a((zahn)var15, var3);
            var3.p.E.put(var8, var15);
         }

         this.b[this.e] = (zahn)var15;
         return null;
      }
   }

   zahn b(zaay var1) {
      if (this.b.length == 1) {
         return this.b[0];
      } else if (this.b.length == 2) {
         return zayc.a(this.b[0], this.b[1], var1, new zlj(var1, true));
      } else {
         return (zahn)(this.c != 1 && this.d != 1 ? new zaws(this.b, new zlj(var1, true), var1) : new zawr(this.b, new zlj(var1, true), var1));
      }
   }
}
